#pragma once
#include "BaseEntity.h"
#include "Singleton.h"
#include "BasePlayer.h"
#include <sfml/Graphics/RenderWindow.hpp>
#include "Model.h"
#include "Vector2.h"
#include "Region.h"

/*
	Ball
	The soccer ball..TODO
*/

class Ball : public BaseEntity, public Singleton<Ball>
{

public:
	void Init();
	~Ball();
	
	void Update(const sf::Input& input);
	void OnDraw(sf::RenderWindow& window);
	void DrawOnRadar(sf::RenderWindow& window,const sf::Vector2f& offset);

	bool HandleMessage(const Telegram& msg);

	Vector2 ComputeFuturePosition(float futureTime);
	Vector2 ComputeFuturePosition(float futureTime, Vector2 speed);
	void CapturedBy(BasePlayer* newOwner);
	void Kick(const Vector2& force);
	void PrepareKickOff(const Vector2& position);

	inline void BounceX() { m_speed.x *= -1; };
	inline void BounceY() { m_speed.y *= -1; };

	inline void SetInPass(bool inPass) { m_inPass = inPass;}
	inline bool IsInPass()const { return m_inPass;}

	inline bool IsControlled()const{ return m_controlledByPlayer;}
	inline BasePlayer* GetOwner()const{ return m_owner;}

private:

	BasePlayer*			m_owner;
	bool				m_controlledByPlayer;
	float				m_speedAttenuation;

	bool				m_inPass;

	Model*				m_model;

};
